package com.tianshuo.construct.main;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.io.Resource;

import java.io.IOException;

/**
 * @ClassName : ResourceApplicationContext
 * @Description : 资源加载器 测试spring自带的resource加载器，加载数据
 * @Author : tianshuo
 * @Date: 2021-09-12 17:39
 */
public class ResourceApplicationContext {
    public static void main(String[] args) throws IOException {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();

//        Resource[] resources = applicationContext.getResources("classpath:com/tianshuo/aop/*/*.class");
//
//        for (Resource resource : resources) {
//            System.out.println(resource.getFile());
//            System.out.println(resource.getFilename());
//        }

        Resource resource = applicationContext.getResource("https://www.baidu.com");
        System.out.println(resource.contentLength());
        System.out.println(resource.getURL());

        Resource resource1 = applicationContext.getResource("classpath:test.properties");
        System.out.println(resource1.getFilename());
        System.out.println(resource1.getFile());
    }
}

